<template>
  <view class="explain">
    <view class="jinayi">
      <view class="jianyi_title">拍照建议</view>
      <view class="jianyi_info">1.找他人协助，用后置摄像头拍摄</view>
      <view class="jianyi_info">2.表情自然，抬头挺胸，两眼平时前方</view>
      <view class="jianyi_info">3.穿深色衣服，在白色背景墙前拍摄效果最佳</view>
    </view>
    <view class="jinayi">
      <view class="jianyi_title">照片规格说明</view>
      <view class="jianyi_info guigeinfo">
        <view class="guigeleft">打印尺寸：</view>
        <view>{{info.sizeNum}}</view>
      </view>
      <view class="jianyi_info guigeinfo">
        <view class="guigeleft">像素尺寸：</view>
        <view>{{info.sizePx}}</view>
      </view>
      <view class="jianyi_info guigeinfo">
        <view class="guigeleft">文件大小：</view>
        <view>{{info.size ? info.size +'kb':  '无要求'}}</view>
      </view>
      <view class="jianyi_info guigeinfo">
        <view class="guigeleft">分变率：</view>
        <view>{{info.dpi? info.dpi +'dpi': '无要求'}}</view>
      </view>
      <!-- <view class="jianyi_info guigeinfo">
        <view class="guigeleft">背景色：</view>
        <view class="guigeright" v-if="info.color_arr">
          <block v-for="(item,index) in info.color_arr" :key="index">
            <view  class="circle"
              :style="'background:'+ item"></view>
          </block>
        </view>
      </view> -->
    </view>
    <view class="jinayi">
      <view class="jianyi_title">照片下载说明</view>
      <view class="jianyi_info guigeinfo">
        <view class="guigeleft">水印：</view>
        <view>下载的照片会去掉水印</view>
      </view>
      
    </view>
    <view class="footer">
      <view @click="selectImg(0)">相册选择（推荐）</view>
      <view @click="selectImg(1)">直接拍摄</view>
    </view>
  </view>
</template>
<script>
import listSize from '../../util/data.js'
import {fileBase64Size} from '../../util/imgSize.js'
import {getAccessToken} from '../../util/api.js'
export default {
  onLoad(option) {
    this.id = option.id
    let data = listSize.find(item => {
      return item.id == option.id
    })
    this.info = data;
    uni.setNavigationBarTitle({
      title: data.name
    })

  },
  data() {
    return {
      id: '',
      info: {}
    }
  },
  methods: {
    toCreate(filePath) {
      uni.navigateTo({
        url: `/pages/create/index?id=${this.id}&filePath=${filePath}`
      })
    },
    selectImg(selectid){
      let _this = this
      let typelist = selectid === 1 ? ['camera'] : ['album']
      uni.chooseImage({
        count: 1,
        sourceType: typelist,
        success: (res)=> {
          fileBase64Size(res.tempFilePaths[0]).then(length => {

            if (length > 4 * 1024 * 1024) {
              uni.showToast({
                title: '上传图片最大为4M,请重新选择图片',
                icon:'none',
                duration: 2000
              });
            }else{
              _this.toCreate(res.tempFilePaths[0])
            }
          })
        }
      });
    }
  }
}
</script>
<style>
@import './index.css';
</style>